// Problem: 
// Contest: 
// URL: 
// Memory Limit: 
// Time Limit: 
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#include<bits/stdc++.h>
using namespace std;
#define int long long
inline int read(){
	int s=0,w=1;
	char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
	while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
	return s*w;
}
struct pos
{
	int x,c=0;
	pos(int a,int z)
	{
		x=a,c=z;
	}
};
signed main()
{
	int n,a,b;
	cin>>n>>a>>b;
	vector<int> v(n+1),f(n+1);
	for(int i=1;i<=n;i++)
	{
		cin>>v[i];
	}
	queue<pos> q;
	q.push(pos(a,0));
	f[a]=1;
	while(!q.empty())
	{
		pos tmp=q.front();
		int c=tmp.c,x=tmp.x;
		if(x==b)
		{
			cout<<c;
			return 0;
		}
		q.pop();
		int a=x+v[x];
		if(a<=n&&f[a]==0)
		{
			q.push(pos(a,c+1));
			f[a]=1;
		}
		a=tmp.x-v[x];
		if(a>=1&&f[a]==0)
		{
			q.push(pos(a,c+1));
			f[a]=1;
		}
	}
	cout<<"-1";
	return 0;
}
